package com.gitee.cui.es;

import java.io.IOException;

import org.apache.http.HttpHost;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

/**
 * ES索引查询操作
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022-04-05 15:56
 **/
public class ESIndexSearch {

	public static void main(String[] args) throws IOException {
		RestHighLevelClient client = new RestHighLevelClient(
				RestClient.builder(new HttpHost("localhost", 9200, "http")));

		// 查询索引
		GetIndexRequest userIndex = new GetIndexRequest("user");
		GetIndexResponse response = client.indices().get(userIndex, RequestOptions.DEFAULT);

		System.out.println(response.getAliases());
		System.out.println(response.getMappings());
		System.out.println(response.getSettings());
		client.close();
	}
}
